package com.meng.system.service.impl.auth;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.meng.system.domain.vo.SysMenuVO;
import com.meng.system.mapper.auth.SysMenuMapper;
import com.meng.system.security.MiniUserDetails;
import com.meng.system.service.auth.SysMenuService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 菜单权限表 服务实现类
 * </p>
 *
 * @author Xu Meng
 * @since 2021-01-14
 */
@Slf4j
@RequiredArgsConstructor//bean构造注入注解
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenuVO> implements SysMenuService {

    private final SysMenuMapper sysMenuMapper;

    /**
     * 获取菜单树
     * @return 菜单树返回结果集
     */
    @Override
    public List<SysMenuVO> findMenuTreeList() {
        //获取当前登录用户的菜单树
        MiniUserDetails principal = (MiniUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return sysMenuMapper.findMenuTreeList(principal.getUserId());
    }
}
